package com.evil.kingdom.pojo.entity.config.value;

import com.evil.kingdom.pojo.dto.alive.AliveMessageData;
import com.evil.kingdom.pojo.entity.config.ConfigValue;
import jakarta.validation.constraints.Size;
import lombok.Getter;
import lombok.Setter;

/**
 * 黄历
 *
 * @author liyang
 * @date 2024-06-02 19:02
 */
@Setter
@Getter
public class Almanac implements ConfigValue, AliveMessageData {

    private final static Integer MIN = 1;
    private final static Integer MAX_MONTH = 12;
    private final static Integer MAX_DAY = 30;

    /**
     * 黄历年
     */
    @Size(min = 1, message = "黄历年错误")
    private Integer year;

    /**
     * 月份
     */
    @Size(min = 1, max = 12, message = "黄历月错误")
    private Integer month;

    /**
     * 天
     */
    @Size(min = 1, max = 30, message = "黄历日错误")
    private Integer day;

    public Almanac() {
        this.year = MIN;
        this.month = MIN;
        this.day = 0;
    }

    public void addDay() {
        if (day < MAX_DAY) {
            day++;
            return;
        }
        this.day = MIN;
        if (month < MAX_MONTH) {
            month++;
            return;
        }
        this.month = MIN;
        this.year++;
    }
}
